package com.usian.user.controller;

import com.usian.apis.user.ApUserRealnameControllerApi;
import com.usian.common.constants.user.UserConstants.AdminConstans;
import com.usian.model.common.dtos.PageResponseResult;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.user.dtos.AuthDto;
import com.usian.user.service.ApUserRealnameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/Realname")
public class ApUserRealnameController implements ApUserRealnameControllerApi {
    @Autowired
    ApUserRealnameService apUserRealnameService;

    /**
     * 袁浩 2022-6-23
     * 根据状态查询需要认证的用户信息
     * @param dto
     * @return
     */
    @PostMapping("/list")
    @Override
    public PageResponseResult loadListByStatus(@RequestBody AuthDto dto) {
        return apUserRealnameService.loadListByStatus(dto);
    }

    /**
     * 袁浩 2022-6-24
     * 用户认证审核通过
     * @param dto
     * @return
     */
    @PostMapping("/authPass")
    @Override
    public ResponseResult authPass(@RequestBody AuthDto dto) {
        return apUserRealnameService.updateStatusById(dto, AdminConstans.PASS_AUTH);
    }

    /**
     * 袁浩 2022-6-24
     * 用户认证审核失败
     * @param dto
     * @return
     */
    @PostMapping("/authFile")
    @Override
    public ResponseResult authFile(@RequestBody AuthDto dto) {
        return apUserRealnameService.updateStatusById(dto,AdminConstans.FILE_AUTH);
    }
}
